home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / progut~1 / iostream.zoo / include / ioprivat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-22  |  2.5 KB  |  74 lines

  1. //    This is part of the iostream library, providing input/output for C++.
  2. //    Copyright (C) 1991 Per Bothner.
  3. //
  4. //    This library is free software; you can redistribute it and/or
  5. //    modify it under the terms of the GNU Library General Public
  6. //    License as published by the Free Software Foundation; either
  7. //    version 2 of the License, or (at your option) any later version.
  8. //
  9. //    This library is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. //    Library General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU Library General Public
  15. //    License along with this library; if not, write to the Free
  16. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #include "ioconfig.h"
  19.  
  20. #if defined(IMPLEMENT_STDIO) && defined(RENAME_STDIO)
  21. // This is a kludge used by streambuf.C.  It is needed because
  22. // streambuf.C contains the actual definitions of stdio, but
  23. // it lies about their type.  (I.e. the type that streambuf.C
  24. // internally defines stdin to have is not the same as the type
  25. // that stdio.h declares stdin to have.)
  26. #define stdin STDIN
  27. #define stdout STDOUT
  28. #define stderr STDERR
  29. #include "stdio.h"
  30. #undef stdin
  31. #undef stdout
  32. #undef stderr
  33. #include "local.h"
  34. #else
  35. #include <stdio.h>
  36. #endif
  37.  
  38. #include "std.h"
  39. #include "streambu.h"
  40. #include <stdarg.h>
  41.  
  42. #define _fstat(x, y) fstat(x,y)
  43. #define _isatty(fd) isatty(fd)
  44.  
  45. extern int __vsbprintf(streambuf *, char const *, va_list);
  46. extern int __sbprintf(streambuf *sb, const char* format, ...);
  47. extern int __vsbscanf(streambuf *, char const *, va_list);
  48. extern int __sbscanf(streambuf *, char const *, ...);
  49. extern int __sbvwrite(streambuf *fp, struct __suio *uio);
  50. extern int __cvt_double(double number, register int prec, int flags,
  51.             char *signp, int fmtch, char *startp, char *endp);
  52.  
  53. #ifdef IMPLEMENT_STDIO
  54. #define CIN_STREAMBUF stdin
  55. #define COUT_STREAMBUF stdout
  56. #define CERR_STREAMBUF stderr
  57. #define CLOG_STREAMBUF stderr
  58.  
  59. #define __validfp(fp) \
  60.   (((fp->_flags & _IO_MAGIC_MASK) == _OLD_STDIO_MAGIC && \
  61.     (fp = *(FILE**)&((int*)fp)[1])), \
  62.    __checkfp(fp))
  63. #define __checkfp(fp) (fp->_flags & _IO_MAGIC_MASK) == _IO_MAGIC
  64.  
  65. inline streambuf* FILE_to_streambuf(FILE* fp)
  66. {
  67.     if ((fp->_flags & _IO_MAGIC_MASK) == _OLD_STDIO_MAGIC)
  68.     return *(streambuf**)&((int*)fp)[1];
  69.     if ((fp->_flags & _IO_MAGIC_MASK) == _IO_MAGIC)
  70.     return (streambuf*)fp;
  71.     return NULL;
  72. }
  73. #endif
  74.